package com.anmai.crawler1.dao;

import com.anmai.crawler1.base.dao.BaseDao;
import com.anmai.crawler1.entity.AreaBean;
import com.anmai.crawler1.entity.ImgBean;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface ImgDao extends BaseDao<ImgDao>{
//    int deleteByPrimaryKey(Integer id);
//
////    @Insert("insert into area(city_id,area_name,create_time,update_time) values(#{cityId},#{areaName},#{createTime},#{updateTime})")
//    int insert(AreaBean record);
//
//    List<AreaBean> findAreas(AreaBean areaBean);
//
//    int insertSelective(AreaBean record);
//
//    AreaBean selectByPrimaryKey(Integer id);
//
//    int updateByPrimaryKeySelective(AreaBean record);
//
////    @Update("update area set status = #{status,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}")
//    int updateByPrimaryKey(AreaBean record);
//
//    @Select("select count(id) from area where area_name = #{areaName,jdbcType=VARCHAR} and url = #{url,jdbcType=VARCHAR} and city_id = #{cityId,jdbcType=INTEGER}")
//    Integer isExist(AreaBean areaBean);
//
//    @Select("select * from area where status = #{status,jdbcType=INTEGER}")
//    @Results({
//            @Result(property = "updateTime", column = "update_time"),
//
//            @Result(property = "createTime", column = "create_time"),
//
//            @Result(property = "cityId", column = "city_id"),
//
//            @Result(property = "areaName", column = "area_name")
//    })
//    List<AreaBean> findErrorAreas(@Param("status") Integer status);
//
//    //更新状态
//    @Update("update area set status =  #{status,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}")
//    Integer updateStatus(AreaBean areaBean);
//
//    //查找没有商圈的区域
//    @Select("SELECT * from  area WHERE id not in (SELECT area_id FROM bussiness) and status <> -1")
//    @Results({
//            @Result(property = "updateTime", column = "update_time"),
//
//            @Result(property = "createTime", column = "create_time"),
//
//            @Result(property = "cityId", column = "city_id"),
//
//            @Result(property = "areaName", column = "area_name")
//    })
//    List<AreaBean> findAreaNoBussiness();

    /**
     * 新增
     * @param imgBean
     * @return
     */
    @Insert("insert into img(img,status) values(#{img,jdbcType=VARCHAR},#{status,jdbcType=INTEGER})")
    int add(ImgBean imgBean);

    @Select("select * from img where status = #{status,jdbcType=INTEGER} ")
    List<ImgBean> queryByStatus(Integer status);

    /**
     * 更新状态
     * @param imgBean
     * @return
     */
    @Update("update img set status = #{status,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}")
    int update(ImgBean imgBean);

    @Select("select count(id) from img where img = #{img,jdbcType=VARCHAR}")
    int isExist(String img);

}